<form method="post" id="frmFullHouse" name="frmFullHouse" action="{$smarty.const.HOST_VFRIEND}account/basicsave" enctype="multipart/form-data">
	<input type="hidden" name="phascode" id="phascode" value="" />
    <input type="hidden" name="ptsave" id="ptsave" value="{$intType}" />
    <div class="editForm">  	
    	{if $objUser->uname_verify}
        	<p>Username của bạn là <strong>{$AppUI->username}</strong></p>
            <p>Mọi người có thể xem trang cá nhân của bạn qua liên kết:</p>
            <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="{$smarty.const.HOST_VFRIEND}{$AppUI->username}">{$smarty.const.HOST_VFRIEND}<strong>{$AppUI->username}</strong></a></p>
             <input type="button" value="Đóng" class="btnCancel tMargin10 bMargin10" onclick="javascript:basicClose('{$strView}','{$strEdit}')" />
        {else}
            <p>Bạn chỉ có thể áp dụng việc thay đổi Username để tạo Url friendly của Full-house một lần duy nhất.</p>
            <div class="userInput">
                <label>Username:</label>
                <input type="text" value="{if isset($smarty.session.st_username)}{$smarty.session.st_username|escape}{else}{$objUser->username|escape}{/if}" id="pusername" name="pusername" maxlength="30" class="text clearIt" />	
            </div>
            <div class="userInput">
                <label>Mật khẩu {$smarty.const.DOMAIN_NAME} của bạn:</label>
                <input type="password" value="" id="ppassword" name="ppassword" maxlength="30" class="text clearIt" />	
            </div>
            <div class="userInput">
                <input type="submit" value="Thay đổi" class="btnSubmit" />
                <input type="button" value="Hủy" class="btnCancel" onclick="javascript:basicClose('{$strView}','{$strEdit}')" />
            </div>
        {/if}
   	</div>
</form>
{literal}
<script type="text/javascript" language="javascript">
	$(document).ready(function(){
		$("#frmFullHouse").validate({				
			errorClass		: "errorMessage",
			errorElement	: "span",
			onfocusout		: false,
			onkeyup			: false,
			rules: {	
				pusername: {
					required			: true,
					rangelength			: [5,30],
					validUsername		: true,
					isExistUsername		: true					
				},
				ppassword:{
					passwordValidate	: true
				}
			},
			messages: {	
				pusername: {
					required			: username_required,
					rangelength			: username_range,
					validUsername		: username_format,
					isExistUsername		: username_validate
					
				},
				ppassword:{
					passwordValidate	: password_invalid
				}
			},		
			errorPlacement: function(label, element) {			
				var id = element.attr("id");			
				label.insertAfter($("#" + id));			
			},
			submitHandler: function(form) {				
				form.submit();
			}
		});	
		$.validator.addMethod("validUsername", function(){
			var strUsername = $("#pusername").val();
			return validateUsername(strUsername);
		});
		$.validator.addMethod("validUsername", function(){
			var result 			= true;
			var strUsername		= $("#pusername").val();		
			var strUrl 			= HOST_VFRIEND + "valid/isvalidusername";			
			$.ajax({
				cache	: false,
				async	: false,
				type	: "POST",
				data	: "username=" + strUsername,
				url		: strUrl,
				success	: function(response) {
					result = (response == 1) ? true : false;
				}
			});
			return result;		
		});
		$.validator.addMethod("passwordValidate", function(){
			var result 			= true;
			var strPassword		= $("#ppassword").val();
			var strHasPassword	= MD5(MD5(strGeneralCode) + MD5(strPassword));				
			var strUrl 			= HOST_VFRIEND + "valid/isvalidpassword";
			$("#ppassword").val("");
			$("#phascode").val(strHasPassword);
			$.ajax({
				cache	: false,
				async	: false,
				type	: "POST",
				data	: "password=" + strHasPassword,
				url		: strUrl,
				success	: function(response) {
					result = (response == 1) ? true : false;
				}
			});
			return result;								   
		});		
	});
</script>
{/literal}